﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RadioThermostat.Common;


namespace RadioThermostat
{
    public class RTThermostat
    {
        private string ip;
        private readonly string name;
        private readonly RTTempSettings tempSettings;
        private readonly RTSys system;
        private readonly WebCommunicator webCommunicator;

        
        public RTThermostat(string name, string ip)
        {
            this.name               = name;
            this.ip                 = ip;
            this.webCommunicator    = new WebCommunicator();   //only one webcommunicator per rtthermostat
            this.tempSettings       = new RTTempSettings(this);
            this.system             = new RTSys(this);
        }

        public RTSys SystemSettings
        {
            get { return this.system; }
        }

        public RTTempSettings TempSettings
        {
            get { return this.tempSettings; }
        }

        public string IP
        {
            get { return this.ip; }
        }

        public string Name
        {
            get { return this.name; }
        }

        public string GetJSON(string command)
        {
            string url = RTUtils.GetURL(this, command);
            return this.webCommunicator.HttpGet(url);
        }

        public WebCommunicator WebCommunicator
        {
            get { return webCommunicator; }
        } 
    }
}
